/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!		\file		CC_Selection.h
		\date		june 2010
		\author		TNick

		\brief		Contains the definition of CC_Selection class and related


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please read ReadMe.txt and Licence.txt in root folder
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef		__CC_SELECTION_INC__
#define		__CC_SELECTION_INC__
#ifdef		__cplusplus
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class	CC_Graphic;
class	CC_DrawSpace;
#include	<assert.h>

#include	<QList>
#include	<QString>

/*  INCLUDES    ============================================================ */
//
//
//
//


/// this class groups together pointers to items that together form a selection set
/**
*	The class inherits QList. The methods of thta class are mostly used:
*	- append: to add an item at the end of the list
*	- count: number of items
*	- indexOf: the location of a particular item or -1 if not in selection
*	- insert: add an item in the middle of the list
*	- removeAt: to remove a random item
*	- at or value: the item at index i
*/
class	CC_Selection : public QList<CC_Graphic*>	{

	//
	//
	//
	//
	/*  DEFINITIONS    --------------------------------------------------------- */


	/*  DEFINITIONS    ========================================================= */
	//
	//
	//
	//
	/*  DATA    ---------------------------------------------------------------- */

	/// the name of this selection (may be empty)
	QString			str_name;

	/// pointer to associated space; all items are present in this space
	CC_DrawSpace*	pSpace;

	/*  DATA    ================================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ----------------------------------------------------------- */

	/// constructor;
private:					CC_Selection	();
	/// constructor;
private:					CC_Selection	(
			QString			pNewName,
			CC_DrawSpace*	pNewSpace = 0
										);


	/// destructor; will free resources; not virtual;
public: virtual				~CC_Selection();



	/// get the name of selection
public: inline QString			Name(void)
		{ return str_name; }
	/// set the name of selection
public: inline void				setName(QString pNewN)
		{ str_name = pNewN; }
	/// set the name of selection
public: inline void				setName(QString* pNewN)
		{ str_name = *pNewN; }


	/// get associated space
public: inline CC_DrawSpace*	Space(void)
		{ return pSpace; };
	/// set associated space
public: inline void				setSpace(CC_DrawSpace* pNewSpace)
		{ Q_ASSERT(pSpace == NULL); pSpace = pNewSpace; };


	/// reimplement append
public: inline void				append		(CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::append(t); /// call base function
		}
	/// reimplement append
public: void					append		(QList<CC_Graphic*> &t);

	/// reimplement insert
public: inline void				insert		(int i, CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::insert(i, t); /// call base function
		}

	/// reimplement insert
public: inline void				prepend		(CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::prepend(t); /// call base function
		}

	/// reimplement push_back
public: inline void				push_back	(CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::push_back(t); /// call base function
		}

	/// reimplement push_front
public: inline void				push_front	(CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::push_front(t); /// call base function
		}

	/// reimplement push_front
public: inline void				replace 	(int i, CC_Graphic* &t)
		{	if (!validate(t)) /// if all is OK
			return;
			QList<CC_Graphic*>::replace(i, t); /// call base function
		}

	/// reimplement append operator
private: CC_Selection &operator+=(QList<CC_Graphic*> &l)
									 {
			Q_UNUSED(l);
			return *this;
		}
	/// reimplement append operator
private: CC_Selection &operator+=(CC_Graphic* &l)
									 {
			Q_UNUSED(l);
			return *this;
		}
	/// reimplement append operator
private: CC_Selection &operator<<(QList<CC_Graphic*> &l)
		{
			Q_UNUSED(l);
			return *this;
		}
	/// reimplement append operator
private: CC_Selection &operator<<(CC_Graphic* &l)
		{
			Q_UNUSED(l);
			return *this;
		}






	/// see if the item is ok to be added to this selection
private: bool					validate	(CC_Graphic* it);



	/*  FUNCTIONS    =========================================================== */
	//
	//
	//
	//




};	/*	class	CC_Selection	*/
//
//
//
//
#endif	//	__cplusplus
#endif	//	__CC_SELECTION_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
